package com.wzcl.app.dao.repository;

import com.wzcl.app.dao.model.SendPath;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SendPathRepository extends JpaRepository<SendPath,Integer>, JpaSpecificationExecutor<SendPath> {

    @Query("SELECT m FROM SendPath m where m.userPhone = ?1 AND  m.isDefault = true AND m.state = 0")
    SendPath findDefaultPathByUserPhone(String phone);

    @Query("SELECT m FROM SendPath m where m.userPhone = ?1 AND m.state = 0")
    List<SendPath> findAllByUserPhone(String phone);

    @Query("SELECT m FROM SendPath m where m.id = ?1")
    SendPath findAllById(Integer id);
}
